"""
Copyright (c) 2023 - present SKbioinfo
"""

from flask_restful import Resource, reqparse
from flask import request,jsonify
from flask_login import login_required
from apps.NGS_API.utils.log_helper import lg
from apps.NGS_API.connector.db_common import *
from apps.NGS_API.common.common_time import *
from apps.NGS_API.common.db_table_config import *

class interfaceRole(Resource):
    def get(self):
        try:
            ### SQL: Role infos from database ###
            cols = '''
                id,
                name,
                detail
            '''
            role_info_query_sql = '''
                SELECT 
                    {cols}
                FROM {table_name}
            '''.format(
                cols = cols,
                table_name = role_db["name"]
            )
            role_query_results = query_info(role_info_query_sql)
            role_infos = []
            for role in role_query_results:
                role_infos.append({
                    "id": role[0],
                    "role_id": role[1],
                    "role_detail": role[2]
                })
            response=jsonify(role_infos)
            response.status=202
            return response
        except Exception as e:
            lg.error(e)